﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Data.SqlTypes;

namespace WebApplication1
{
    public partial class Newuser : System.Web.UI.Page
    {
        private string Сon = @"Data Source=LOCALHOST\SQLEXPRESS;Initial Catalog=Test;
Integrated Security=True;Pooling=False";
        private int role;
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button4_Click(object sender, EventArgs e)
        {
            role = 0;
            SqlConnection connection = new SqlConnection(Сon);
            connection.Open();
            if (CheckBox1.Checked == true)
            {
                role = 2;
            }
            else { 
                role = 1;
            }
            SqlCommand сommand1 = new SqlCommand("insert into User1 (Password,Role,Name,Surname,Phone,Email,Login)" +
                "VALUES ('" +TextBox4.Text+"','"+role+"','"+TextBox1.Text+"','"+TextBox2.Text+"','"+Convert.ToInt32(TextBox6.Text)+"','"+TextBox7.Text+"','"+TextBox3.Text+ "')", connection);
            сommand1.ExecuteNonQuery();

            connection.Close();
            Label1.Visible = true;
            TextBox1.Text = "";
            TextBox2.Text = "";
            TextBox3.Text = "";
            TextBox4.Text = "";
            CheckBox1.Checked=false;
            TextBox6.Text = "";
            TextBox7.Text = "";
        }
    }
}
